/*******************************************************************************
 * Copyright (c) 2011 Irineu Martins de Lima Moura (imlm2).
 * This file is part of JBeat.
 * 
 *     JBeat is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     JBeat is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 * 
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with JBeat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 *     Irineu Martins de Lima Moura (imlm2) - initial API and implementation
 ******************************************************************************/
package br.ufpe.cin.imlm2.jbeat.soot.common;

import soot.Scene;
import soot.SootClass;

/**
 * This class contains methods to access SootClass objects of common exceptions.
 * Such methods should only be called after the corresponding classes have been resolved by Soot.
 * @author Irineu
 *
 */
public class CommonExceptions {

	private static SootClass NULLPOINTER;
	private static SootClass ARRAYINDEXOUTOFBOUNDS;
	private static SootClass NEGATIVEARRAYSIZE;
	private static SootClass ILLEGALMONITORSTATE;
	private static SootClass CLASSCAST;
	private static SootClass ARITHMETIC;
	private static SootClass ARRAYSTORE;
	private static SootClass EXCEPTION;
	private static SootClass RUNTIME;
	private static SootClass THROWABLE;
	private static SootClass ERROR;
	
	
	public static SootClass getERROR() {
		if(ERROR == null) ERROR = Scene.v().getSootClass("java.lang.Error");
		return ERROR;
	}
	public static SootClass getTHROWABLE() {
		if(THROWABLE == null) THROWABLE = Scene.v().getSootClass("java.lang.Throwable");
		return THROWABLE;
	}
	public static SootClass getRUNTIME() {
		if(RUNTIME == null) RUNTIME = Scene.v().getSootClass("java.lang.RuntimeException");
		return RUNTIME;
	}
	public static SootClass getEXCEPTION() {
		if(EXCEPTION == null) EXCEPTION = Scene.v().getSootClass("java.lang.Exception");
		return EXCEPTION;
	}
	public static SootClass getNULLPOINTER() {
		if(NULLPOINTER == null) NULLPOINTER = Scene.v().getSootClass("java.lang.NullPointerException");
		return NULLPOINTER;
	}
	public static SootClass getARRAYINDEXOUTOFBOUNDS() {
		if(ARRAYINDEXOUTOFBOUNDS == null) ARRAYINDEXOUTOFBOUNDS  = Scene.v().getSootClass("java.lang.ArrayIndexOutOfBoundsException");
		return ARRAYINDEXOUTOFBOUNDS;
	}
	public static SootClass getNEGATIVEARRAYSIZE() {
		if(NEGATIVEARRAYSIZE == null) NEGATIVEARRAYSIZE = Scene.v().getSootClass("java.lang.NegativeArraySizeException");
		return NEGATIVEARRAYSIZE;
	}
	public static SootClass getILLEGALMONITORSTATE() {
		if(ILLEGALMONITORSTATE == null) ILLEGALMONITORSTATE = Scene.v().getSootClass("java.lang.IllegalMonitorStateException");
		return ILLEGALMONITORSTATE;
	}
	public static SootClass getCLASSCAST() {
		if(CLASSCAST == null) CLASSCAST = Scene.v().getSootClass("java.lang.ClassCastException");
		return CLASSCAST;
	}
	public static SootClass getARITHMETIC() {
		if(ARITHMETIC == null) ARITHMETIC = Scene.v().getSootClass("java.lang.ArithmeticException");
		return ARITHMETIC;
	}
	public static SootClass getARRAYSTORE() {
		if(ARRAYSTORE == null) ARRAYSTORE = Scene.v().getSootClass("java.lang.ArrayStoreException");
		return ARRAYSTORE;
	}
	
}
